{% load i18n mezzanine_tags comment_tags %}

<ul class="unstyled">
    {% for comment in comments_for_thread %}

    <li id="comment-{{ comment.id }}"
        {% if comment.by_author %}class="comment-author"{% endif %}>
        {% editable comment.is_public comment.is_removed %}
        {% if not comment.is_removed and comment.is_public %}

        <strong>
            {% if comment.url %}
            <a href="{{ comment.url }}">
                <img src="{% gravatar_url comment.email %}">
                {{ comment.user_name }}
            </a>
            {% else %}
            <img src="{% gravatar_url comment.email %}">
            {{ comment.user_name }}
            {% endif %}
        </strong>
        <span class="timespan">{{ comment.submit_date|timesince }} {% trans "ago" %}</span>
        <p>{{ comment.comment|comment_filter }}</p>

        <a href="{{ request.path }}#comment-{{ comment.id }}">{% trans "Link" %}</a> /
        <a href="#reply-{{ comment.id }}" class="reply">{% trans "Reply" %}</a>
        <form class="reply-form" method="post" id="reply-{{ comment.id }}"
            action="{{ comment_url }}#reply-{{ comment.id }}"
            {% if replied_to != comment.id %}style="display:none;"{% endif %}>
            {% if replied_to == comment.id %}
            {% fields_for posted_comment_form %}
            {% else %}
            {% fields_for unposted_comment_form %}
            {% endif %}
            <input type="hidden" name="replied_to" value="{{ comment.id }}">
            <input class="btn btn-primary btn-large" type="submit" value="{% trans "Reply" %}">
        </form>

        {% else %}

        {% if request.user.is_staff %}
        <strong>
            {% if comment.url %}
            <a href="{{ comment.url }}">
                <img src="{% gravatar_url comment.email %}">
                {{ comment.user_name }}
            </a>
            {% else %}
            <img src="{% gravatar_url comment.email %}">
            {{ comment.user_name }}
            {% endif %}
        </strong>
        <span class="timespan">{{ comment.submit_date|timesince }} {% trans "ago" %}</span>
        <p>{{ comment.comment|comment_filter }}</p>
        {% endif %}

        <p>
            {% if comment.is_removed %}
            {% trans "Comment deleted" %}
            {% else %}
            {% trans "Comment awaiting approval" %}
            {% endif %}
            <span class="timespan">{{ comment.submit_date|timesince }} {% trans "ago" %}</span>
        </p>

        {% endif %}
        {% endeditable %}
        {% comment_thread comment %}
    </li>
    {% endfor %}
    {% if no_comments %}
    <li>{% trans "There are currently no comments" %}</li>
    {% endif %}
</ul>

